package com.tcm.logistics.service.impl;

import com.base.core.pager.PageBean;
import com.base.core.pager.PageContext;
import com.tcm.logistics.dao.mapper.LogisticsExpressMapper;
import com.tcm.logistics.entity.LogisticsExpress;
import com.tcm.logistics.service.LogisticsExpressService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService(version = "0.0.1-alpha")
public class LogisticsExpressServiceImpl implements LogisticsExpressService {

    @Autowired
    private LogisticsExpressMapper logisticsExpressMapper;

    /**
     * 物流快递公司
     *
     * @param start
     * @param pagesize
     * @return
     */
    @Override
    public PageBean<LogisticsExpress> listPageExpress(Long start, Long pagesize) {
        List<LogisticsExpress> expressList = logisticsExpressMapper.listExpressPage(start,pagesize);
        PageBean<LogisticsExpress> logisticsPageBean = new PageBean<LogisticsExpress>(expressList,
                PageContext.getDataCount(), start, pagesize);
        return logisticsPageBean;
    }

    @Override
    public LogisticsExpress findExpressById(Long id) {
        return logisticsExpressMapper.findByKey(id);
    }

    /**
     * 新增快递公司
     *
     * @param logistics
     */
    @Override
    public void create(LogisticsExpress logistics) {
        logisticsExpressMapper.insert(logistics);
    }

    /**
     * 更新快递公司
     *
     * @param logistics
     */
    @Override
    public void update(LogisticsExpress logistics) {
        logisticsExpressMapper.updateByKey(logistics);
    }

    /**
     * 逻辑删除快递公司
     *
     * @param id
     * @return
     */
    @Override
    public int deleteLogicById(Long id) {
        return logisticsExpressMapper.deleteLogicByKey(id);
    }

    /**
     * 删除快递公司
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById(Long id) {
        return logisticsExpressMapper.deleteByKey(id);
    }
}
